package com.pro.framework.api;

public class PriceCalculator {
    public static void main(String[] args) {
        // 商品信息
        double costPrice = 100; // 成本价（CNY）
        double length = 30; // 包裹长度（cm）
        double width = 20;  // 包裹宽度（cm）
        double height = 10; // 包裹高度（cm）
        double weight = 1.2; // 实际重量（KG）

        // 轻抛系数
        double volumetricFactor = 8000; // 轻抛系数
        double volumetricWeight = (length * width * height) / volumetricFactor; // 计算抛重
        double chargeableWeight = Math.max(weight, volumetricWeight); // 计费重量

        // 物流成本
        double firstWeightPrice = 5; // 首重价格（CNY / 1 KG）
        double additionalWeightPrice = 2; // 续重价格（CNY / 1 KG）
        double shippingCost = (chargeableWeight <= 1) ? firstWeightPrice : firstWeightPrice + (chargeableWeight - 1) * additionalWeightPrice;

        // 平台费用 & 利润计算
        double profitRate = 0.03; // 利润率 3%
        double platformCommissionRate = 0.03; // 平台佣金费率 3%
        double transactionFeeRate = 0.01; // 交易手续费率 1%
        double withdrawalFeeRate = 0.01; // 提现手续费率 1%
        double sfpServiceFeeRate = 0.00; // SFP 服务费率（未知，设 0）
        double influencerCommissionRate = 0.00; // 达人佣金费率（未知，设 0）
        double otherFees = 0; // 其他费用（未知，设 0）

        // 计算最终售价（反向推导）
        double totalRate = profitRate + platformCommissionRate + transactionFeeRate + withdrawalFeeRate;
        double targetPrice = (costPrice + shippingCost) / (1 - totalRate); 

        // 计算各项费用（按售价计算）
        double platformCommission = targetPrice * platformCommissionRate;
        double transactionFee = targetPrice * transactionFeeRate;
        double withdrawalFee = targetPrice * withdrawalFeeRate;
        double sfpServiceFee = targetPrice * sfpServiceFeeRate;
        double influencerCommission = targetPrice * influencerCommissionRate;
        double profit = targetPrice * profitRate;

        // 输出结果
        System.out.printf("最终售价: %.2f CNY%n", targetPrice);
        System.out.printf("成本价: %.2f CNY%n", costPrice);
        System.out.printf("包裹尺寸: %.1fcm x %.1fcm x %.1fcm%n", length, width, height);
        System.out.printf("实际重量: %.2f KG%n", weight);
        System.out.printf("抛重: %.2f KG%n", volumetricWeight);
        System.out.printf("计费重量: %.2f KG%n", chargeableWeight);
        System.out.printf("运费（藏价）: %.2f CNY%n", shippingCost);
        System.out.printf("平台佣金 (3%%): %.2f CNY%n", platformCommission);
        System.out.printf("交易手续费 (1%%): %.2f CNY%n", transactionFee);
        System.out.printf("提现手续费 (1%%): %.2f CNY%n", withdrawalFee);
        System.out.printf("SFP 服务费: %.2f CNY%n", sfpServiceFee);
        System.out.printf("达人佣金: %.2f CNY%n", influencerCommission);
        System.out.printf("利润 (3%%): %.2f CNY%n", profit);
    }
}
